﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LiveLocation.Models
{
    public static class LiveLocationModel
    {
        static LiveLocationModel()
        {
            Context = new LiveLocationEntities();
        }

        public static LiveLocationEntities Context { get; set; }

        public static void AddCoordinates(double latitude, double longitude, int trackID)
        {
            Context.CoordinatesSets.Add(new CoordinatesSet { latitude = latitude, longitude = longitude, Track_Id = trackID });
            Context.SaveChanges();
        }

        public static void RemoveCoordinates(int trackID)
        {
            CoordinatesSet Coord = Context.CoordinatesSets.SingleOrDefault(x => x.Track_Id == trackID);
            if (Coord != null)
            {
                Context.CoordinatesSets.Remove(Coord);
                Context.SaveChanges();
            }
        }
        public static void AddIdentity(int phoneID, string userName)
        {
            Context.IdentitySets.Add(new IdentitySet { PhoneId = phoneID.ToString(), UserName = userName });
            Context.SaveChanges();
        }

        public static void RemoveIdentity(int phoneID)
        {
        }

        public static void RemoveIdentity(string userName)
        {
        }

        public static void AddNewTrack(string trackName, int identityID)
        {
        }

        public static void RemoveTrack(int trackID)
        {
        }

    }
}